home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Amiga / strerror.c < prev    next >
C/C++ Source or Header  |  1998-12-25  |  2KB  |  74 lines

  1. RCS_ID_C="$Id: strerror.c,v 4.1 1994/09/29 23:09:02 jraja Exp $";
  2. /*
  3.  *      strerror.c - network errno support for AmiTCP/IP
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. #include <errno.h>
  11. #include <bsdsocket.h>
  12. #include <amitcp/socketbasetags.h>
  13.  
  14. /****** net.lib/strerror *****************************************************
  15.  
  16.     NAME
  17.         strerror -- return the text for given error number
  18.  
  19.     SYNOPSIS
  20.         string = strerror(error);
  21.  
  22.         char * strerror(int);
  23.  
  24.     FUNCTION
  25.         This function returns pointer to the (English) string describing the
  26.         error code given as argument. The error strings are defined for the
  27.         error codes defined in <sys/errno.h>.
  28.  
  29.     NOTES
  30.         The string pointed to by the return value should not be modified by
  31.         the program, but may be overwritten by a subsequent call to this
  32.         function.
  33.  
  34.     BUGS
  35.         The strerror() prototype should be 
  36.     const char *strerror(unsigned int); 
  37.     However, the SAS C includes define it differently.
  38.  
  39.     SEE ALSO
  40.         <netinclude:sys/errno.h>, perror(), PrintNetFault()
  41. *****************************************************************************
  42. */
  43.  
  44. #include "libcheck.h"
  45.  
  46. extern char *__sys_errlist[];
  47.  
  48. #ifdef notyet
  49. const char *
  50. strerror(unsigned int error)
  51. #else
  52. char *
  53. strerror(int error)
  54. #endif
  55. {
  56.   ULONG taglist[3];
  57.  
  58.   if(!checksocketlib())
  59.   {
  60.     /* cannot use bsdsocket.lib's error strings, use those from SAS */
  61.     PyErr_Clear();
  62.     if(error>=0 && error<=34) return __sys_errlist[error];
  63.     if(error==ELOOP) return "Too many levels of links"; /* link loop */
  64.     else return __sys_errlist[0];
  65.   }
  66.  
  67.   taglist[0] = SBTM_GETVAL(SBTC_ERRNOSTRPTR);
  68.   taglist[1] = error;
  69.   taglist[2] = TAG_END;
  70.  
  71.   SocketBaseTagList((struct TagItem *)taglist);
  72.   return (char *)taglist[1];
  73. }
  74.